import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Index from '../components/Product/index'

import Comm from '../components/Product/components/com/commodity.vue'
import addShop from '../components/Product/components/com/add.vue'
import shop from '../components/Product/components/com/shopDetail.vue'
import edit from '../components/Product/components/com/shopEdit.vue'

import Cate from '../components/Product/components/cate/category.vue'
import child from '../components/Product/components/cate/child.vue'
import addCate from '../components/Product/components/cate/add.vue'


import Order from '../components/Product/components/order/order.vue'
import detail from '../components/Product/components/order/detail.vue'



import Users from '../components/Product/components/user/users.vue'

import echarts from '../components/Product/components/Echarts/Echarts.vue'



import Login from '../components/Login/login'




Vue.use(VueRouter)

const routes = [{
    path: '/',
    redirect: "/product/index"
  },
  //登录
  {
    path: '/login',
    name: "login",
    component: Login
  },
  //首页
  {
    path: '/product/index',
    name: 'Index',
    component: Index,
    meta: {
      title: "首页",
      requireAuth: true
    },
    children: [{
        path: "/",
        name: 'home',
        component: Home,
        meta: {
          title: "首页",
          requireAuth: true
        },
      },
      //商品
      {
        path: "/product/index/comm",
        name: 'comm',
        component: Comm,
        meta: {
          title: "商品管理",
          requireAuth: true
        },
      },
      {
        path: '/classify/index/detail',
        name: 'shopDetail',
        component: shop,
        meta: {
          title: '商品详情',
          flag: true,
        }
      },
      {
        path: '/classify/index/add',
        name: 'shopDetail',
        component: addShop,
        meta: {
          title: '商品管理 -- 添加品类',
          flag: true,
        }
      },
      {
        path: '/classify/index/edit',
        name: 'shopEdit',
        component: edit,
        meta: {
          title: '商品管理--商品修改',
          flag: true,
        }
      },

     //品类
      {
        path: "/product/index/cate",
        name: 'cate',
        component: Cate,
        meta: {
          title: "品类管理",
          requireAuth: true
        },
      },
      {
        path: "/product/index/:id",
        name: 'child',
        component: child,
        meta: {
          title: "品类管理 ",
          requireAuth: true
        },
      },
      {
        path: '/product/index/cate/add',
        name: 'add',
        component: addCate,
        meta: {
          title: '品类管理 -- 添加品类',
          flag: true,
        }
      },

      //订单管理
      {
        path: "/product/index/order/order",
        name: 'order',
        component: Order,
        meta: {
          title: "订单管理",
          requireAuth: true
        },
      },
      //订单详情
      {
        path: "/product/index/order/detail",
        name: 'detail',
        component: detail,
        meta: {
          title: "订单详情",
          requireAuth: true
        },
      },
      {
        path: "/product/index/user/users",
        name: 'users',
        component: Users,
        meta: {
          title: "用户管理",
          requireAuth: true
        },
      },
      {
        path: '/product/index/echarts/echarts',
        name: 'Echarts',
        component: echarts
    
      },

    ]
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import( /* webpackChunkName: "about" */ '../views/About.vue')
  },
  {

    path: '/my',
    name: 'My',
    component: () => import( /* webpackChunkName: "about" */ '../views/My.vue')
  },
  {
    path: '/news',
    name: 'News',
    component: () => import( /* webpackChunkName: "about" */ '../views/News.vue')

  },
  
]

const router = new VueRouter({
  routes
})

export default router